<%--
  Created by IntelliJ IDEA.
  User: zhoushuang
  Date: 2025/6/11
  Time: 上午10:39
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
   <button>注销</button>
</body>
<script>
    const button  = document.querySelector("button");
    button.addEventListener("click", function () {
      const xhr = new XMLHttpRequest();
      xhr.open("POST",'${pageContext.request.contextPath}/login');
      xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
      xhr.send("opr=logout");
      xhr.onreadystatechange = function () {
          if (xhr.readyState === 4 && xhr.status === 200) {
              alert(xhr.responseText);
          }
      }
    })
</script>
</html>
